package com.itheima.day09_set.develophomework;

import java.util.Collections;
import java.util.Comparator;
import java.util.TreeSet;
import java.util.stream.Collectors;

public class Test02 {
    /*
    某it公司项目组总共有8名开发人员，分别是：
"SMITH"、"MARTIN"、"ALLEN"、"SCOTT"、"TURNERS"、"KING"、"MILLER"、"JONES"
项目经理SMITH为了让大家能够快速相互认识，所以决定让团队人员都做一个自我介绍，自我介绍的顺序是：名字越
短越先自我介绍，名字长度一致，那么就按字符串的自然顺序自我介绍。
     */
    public static void main(String[] args) {
        TreeSet<String> t = new TreeSet<>(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                int result = o1.length() - o2.length();
                result = result == 0 ? o1.compareTo(o2) : result;
                return result;
            }
        });
        String[] s = {"SMITH","MARTIN","ALLEN","SCOTT","TURNERS","KING","MILLER","JONES"};
        Collections.addAll(t,s);
        t.forEach(e-> System.out.println(e));
    }
}
